#ifndef __RECE_H__
#define __RECE_H__

/*
 * data: sof + length + cmd + payload + eof
 */
#pragma pack(push)
#pragma pack(1)   // pragma directive to specify the alignment of structs (1 byte)
struct rfid_cmd_packet
{
    uint8_t  sof;
    uint8_t  length;
    uint8_t  cmd;
    uint8_t  payload[100];
    uint8_t  eof;
};
#pragma pack(pop)

typedef struct rfid_cmd_packet  rfid_cmd_packet_t;

/*
 * data: sof + length + cmd + + status + payload + eof
 */
#pragma pack(push)
#pragma pack(1)   // pragma directive to specify the alignment of structs (1 byte)
struct rfid_resp_packet
{
    uint8_t  sof;
    uint8_t  length;
    uint8_t  cmd;
    uint8_t  status;
    uint8_t  payload[100];
    uint8_t  eof;
};
#pragma pack(pop)

typedef struct rfid_resp_packet  rfid_resp_packet_t;

enum
{
	RFID_PACKET_STATE_SOF,
	RFID_PACKET_STATE_DATA,
	RFID_PACKET_STATE_EOF,
};

#define		RFID_PACKET_SOF		    	0xaa
#define		RFID_PACKET_EOF				0x55

/*
 * cmd
 */
#define		RFID_PACKET_CMD		    	0x18

#define     RFID_STATUS_SUCCESS         0x00
#define     RFID_STATUS_FAIL            0x01

uint8_t packet_receiveNext(uint8_t *dat, uint16_t len, rfid_resp_packet_t *packet);
uint16_t generate_packet(uint8_t *dat, uint8_t cmd, uint16_t len, rfid_cmd_packet_t *packet);

#endif